<template>
  <div>
    <sign-header @todayCalendar="todayCalendar"></sign-header>
    <sign-calendar :list="list"></sign-calendar>
    <public-top></public-top>
    <public-menu></public-menu>
  </div>
</template>

<script>
import axios from 'axios'
import { Toast } from 'mint-ui'
import SignHeader from './components/sign/Header'
import SignCalendar from './components/sign/Calendar'
import PublicMenu from '../public/Menu'
import PublicTop from '../public/Top'

export default {
  name: 'Sign',
  components: {
    SignHeader,
    SignCalendar,
    PublicTop,
    PublicMenu
  },
  data () {
    return {
      list: []
    }
  },
  methods: {
    todayCalendar (msg) {
      if (msg === true) {
        axios.get('/meimai/interface/member/signIn', {
          params: {
            memberId: this.$store.state.userId
          }
        }).then((res) => {
          if (res.data.code === 0) {
            Toast('签到成功')
            this.$router.push('/sign')
            this.getInfo()
          } else {
            Toast(res.data.msg)
          }
        })
      }
    },
    getInfo () {
      axios.get('/meimai/interface/member/listSignIn', {
        params: {
          memberId: this.$store.state.userId
        }
      }).then((res) => {
        if (res.data.code === 0) {
          this.list = res.data.data
        }
      })
    }
  },
  mounted () {
    this.getInfo()
  }
}
</script>

<style>
</style>
